package org.javaboy.redis_stream_demo.controller;

import org.javaboy.redis_stream_demo.model.User;
import org.javaboy.redis_stream_demo.service.StreamProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    StreamProducer streamProducer;

    @GetMapping("/hello")
    public void contextLoads() {
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setId(i);
            user.setUsername("javaboy" + i);
            streamProducer.sendMsg(user);
        }
    }
}
